<html>
<head><meta charset="utf-8"><title>import resolution status in rust-analyzer · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/import.20resolution.20status.20in.20rust-analyzer.html">import resolution status in rust-analyzer</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204653890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/import%20resolution%20status%20in%20rust-analyzer/near/204653890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/import.20resolution.20status.20in.20rust-analyzer.html#204653890">(Jul 22 2020 at 11:27)</a>:</h4>
<p><span class="user-mention" data-user-id="123856">@Vadim Petrochenkov</span> I saw you threatening to use inference variables and unification for name resolution in Rust, so I thought I'd mention that, in rust-analyzer, we are organizationally at the point where we could put some work into experimenting with name resolution :-)</p>
<p>As in, we've mostly completed work for eval period of  "transition from rls to rust-analyzer as the offical IDE" RFC, and we haven't yet started library-ifing the parser. The parser is the next planned big thing, but we also could tackle "experimentation" phase of name resolution instead. That is, extracting the shared library is out of the question for now, but we have some manpower to implement proper "resolve imports in parallel" approach and whatever other crazy ideas in rust-analyzer, just to check if they fly at all.</p>
<p>Do you think it would be especially useful to do such experimentation now?</p>
<p>Also, a general periodic reminder for anyone in T-compiler that "extracting name resolution" is an open and mostly independent task, so, if anyone wants to tackle a huge researchy problem, you are welcome :D</p>



<a name="204655144"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/import%20resolution%20status%20in%20rust-analyzer/near/204655144" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/import.20resolution.20status.20in.20rust-analyzer.html#204655144">(Jul 22 2020 at 11:46)</a>:</h4>
<p>To clarify, I'll probably never get to this myself, unless I get fired from my job, because it's not a regression or any other kind of high-priority issue.</p>



<a name="204655202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/import%20resolution%20status%20in%20rust-analyzer/near/204655202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/import.20resolution.20status.20in.20rust-analyzer.html#204655202">(Jul 22 2020 at 11:47)</a>:</h4>
<p>The "unification" idea applies to import resolution specifically, i.e. to "symlink" items that create names referring to other names.</p>



<a name="204655310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/import%20resolution%20status%20in%20rust-analyzer/near/204655310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/import.20resolution.20status.20in.20rust-analyzer.html#204655310">(Jul 22 2020 at 11:49)</a>:</h4>
<p>Right now to resolve an import <code>use foo;</code> we resolve it in environment including anything else, but excluding this import itself.<br>
So that imports cannot refer to names introduced by themselves breaking causality.</p>



<a name="204656266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/import%20resolution%20status%20in%20rust-analyzer/near/204656266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/import.20resolution.20status.20in.20rust-analyzer.html#204656266">(Jul 22 2020 at 12:01)</a>:</h4>
<p>The "unification" idea is to set the resolution of <code>use foo;</code> to a fresh "inference variable" <code>$1</code>.<br>
The obligations on this variable will be <code>$1 == $1</code> (the trivial one, because <code>use foo;</code> is the first <code>foo</code> in scope when resolving <code>use foo;</code>) and <code>$1 == foo from extern prelude</code> because that's the first <code>foo</code> in scope with resolution not containing inference variables.</p>



<a name="204656787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/import%20resolution%20status%20in%20rust-analyzer/near/204656787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/import.20resolution.20status.20in.20rust-analyzer.html#204656787">(Jul 22 2020 at 12:07)</a>:</h4>
<p>As a result we won't resolve different imports in different environment causing potentially confusing cases like <a href="https://github.com/rust-lang/rust/issues/74556">https://github.com/rust-lang/rust/issues/74556</a>, and avoid the name exclusion which always felt a bit like a hack to me.</p>



<a name="204657136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/import%20resolution%20status%20in%20rust-analyzer/near/204657136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/import.20resolution.20status.20in.20rust-analyzer.html#204657136">(Jul 22 2020 at 12:11)</a>:</h4>
<p>I didn't think through this idea in detail or try implementing it, because that would probably mean a ~week of full time == months of sparsely allocated time, but I work slower than other people in general, so someone else could try it faster.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>